//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.amt.olcacon.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import java.io.Serializable;

public class GlobalResponse<G> implements Serializable {
    private static final long serialVersionUID = -1216289902108386500L;
    private String msg;
    private String code;
    @JsonInclude(Include.NON_NULL)
    private G data;

    public GlobalResponse(Responses response) {
        this.msg = response.msg;
        this.code = response.code;
    }

    public GlobalResponse(String code, String msg) {
        this.msg = msg;
        this.code = code;
    }

    public static <M> GlobalResponse<M> success() {
        return success(Responses.SUCCESS);
    }

    public static <M> GlobalResponse<M> success(Responses responses) {
        return new GlobalResponse(responses.getCode(), responses.getMsg());
    }

    public static <M> GlobalResponse<M> error(Responses responses) {
        return new GlobalResponse(responses.getCode(), responses.getMsg());
    }

    public static <M> GlobalResponse<M> error(String responseCode, String responseMsg) {
        return new GlobalResponse(responseCode, responseMsg);
    }

    public static <M> GlobalResponse<M> error(String message) {
        return new GlobalResponse("1101", message);
    }

    public static <M> GlobalResponse<M> of(M data) {
        GlobalResponse<M> success = success();
        success.setData(data);
        return success;
    }

    public String toString() {
        return "GlobalResponse{msg='" + this.msg + '\'' + ", code='" + this.code + '\'' + ", data=" + this.data + '}';
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public G getData() {
        return this.data;
    }

    public void setData(G data) {
        this.data = data;
    }

    public static enum Responses {
        SUCCESS("0", "ok"),
        ERROR("1001", "调用失败"),
        DB_ERROR("1002", "数据变更失败"),
        NO_PERMISSION("1003", "权限验证失败"),
        NO_APP_PERMISSION("1004", "没有当前系统权限，请联系管理员"),
        USER_PASSWD_INVALID("1005", "用户名或密码错误"),
        MISSING_NECESSARY_PARAMS("1106", "必要请求参数缺失"),
        WRONG_VERIFY_CODE("1107", "图片验证码不正确, 请重试"),
        WRONG_MSG_CODE("1108", "短信验证码不正确, 请重试"),
        REGISTER_ALREADY("1109", "您已注册"),
        SMS_SENT("1110", "验证码已发送"),
        FREQUENT_REQ("1111", "请求过于频繁"),
        SMS_SENT_FAIL("1112", "验证码发送失败"),
        ORDER_NOT_EXISTS("1113", "补货单不存在"),
        MOLD_NOT_EXISTS("1114", "模号不存在"),
        MOLDS_NOT_MAPPING_TO_ONE("1116", "模号对应多个商品"),
        NOTHING_CHANGED("1117", "用户未做修改"),
        REGISTER_NO("1118", "您未注册请注册");

        private String code;
        private String msg;

        private Responses(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public String getCode() {
            return this.code;
        }

        public String getMsg() {
            return this.msg;
        }
    }
}
